Ticket #4969: Convert To Momentum Transfer.py

File Convert To Momentum Transfer.py, 1.1 KB (added by Owen Arnold, 9 years ago)
Line 
1from mantidsimple import *
2
3PIX=1.1E-3 #m
4RunNo=4699
5RIO=[69,80]
6DB=[26,31]
7Theta=0.49
8SC=175
9
10X=mtd['POLREF00004699']
11ConvertUnits(InputWorkspace=X,OutputWorkspace=X,Target="Wavelength",AlignBins="1")
12CropWorkspace(InputWorkspace=X,OutputWorkspace='Io',XMin=0.8,XMax=14.5,StartWorkspaceIndex=2,EndWorkspaceIndex=2)
13CropWorkspace(InputWorkspace=X,OutputWorkspace='D',XMin=0.8,XMax=14.5,StartWorkspaceIndex=3)
14Io=mtd['Io']
15D=mtd['D']
16
17Divide(D,Io,'I','1','1')
18I=mtd['I']
19
20ConvertSpectrumAxis(InputWorkspace=I,OutputWorkspace='tl1',Target='signed_theta')
21
22inst=I[0].getInstrument()
23sampleLocation=inst.getComponentByName('some-surface-holder').getPos()
24detLocation=inst.getComponentByName('pointdetector').getPos()
25sample2detector=detLocation-sampleLocation    # meters
26
27# Move the detector so that the detector channel matching the reflected beam is at 0,0
28MoveInstrumentComponent(Workspace=I,ComponentName="lineardetector",X=0,Y=0,Z=-PIX*(SC))
29
30#CloneWorkspace(I,'I2')
31ConvertSpectrumAxis(InputWorkspace=I,OutputWorkspace='tl2',Target='signed_theta')
32
33ConvertUnits(InputWorkspace='tl2',OutputWorkspace='x_in_q',Target='MomentumTransfer',EMode='Indirect')